<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  <style>
	  .content{
	      margin:auto;
	      margin-top:50px;
	      width:700px;
		  height:500px;
		  border:1px solid #000;
	  }
	  ul{
	     list-style:none;
		 margin-top:-10px;
		 padding:0px;
		 height:100%;
		 border-right:1px solid #000;
	  }
      .content_left{
	     float:left;
	     width:100px;
		 height:100%;
	  }	  
	  
	  .content_left li{
	     margin-top:10px;
	     padding-top:10px;
	     border-bottom:1px solid red;
		 cursor:pointer;
	  }
	  .contetn_right{
	     float:right;
	     width:590px;
		 height:100%;
	  }
	  
	  .btn_form{
	     margin-top:20px;
	  }
	  
	  .btn_context {
	     margin-left:30px;
	  }
	  .username{
	    margin-top:40px;
	    margin-left:300px;
	  }

	  </style>
	  
	  <script type="text/javascript">
	  window.onload = function() {
	    var ReloadEntitybtn = document.getElementById("ReloadEntitybtn");
	    
	    var DeleteEntitybtn = document.getElementById("DeleteEntitybtn");
	    
	    var GetEntitybtn = document.getElementById("GetEntitybtn");
	    
	    var xhr =  createXHR();
	    
	    ReloadEntitybtn.onclick = function (){
	          var dcmpmethod = "ReloadEntity";
		      var url = "test?flog=1";
			  xhr.open("POST", url, true);
			  xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			  xhr.send("dcmpmethod="+dcmpmethod);
			  xhr.onreadystatechange = function() {		 
				if (xhr.readyState == 4 && xhr.status == 200) {    
					var result = xhr.responseText;					 
					document.getElementById("c_right").innerHTML=result;
				}
			}
		}
		
		 DeleteEntitybtn.onclick = function (){
		      var dcmpmethod = "DeleteEntity";
		      var url = "test?flog=1";
			  xhr.open("POST", url, true);
			  xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			  xhr.send("dcmpmethod="+dcmpmethod);
			  xhr.onreadystatechange = function() {		 
				if (xhr.readyState == 4 && xhr.status == 200) {    
					var result = xhr.responseText;					 
					document.getElementById("c_right").innerHTML=result;
				}
			}
		}
		
		 GetEntitybtn.onclick = function (){
		      var dcmpmethod = "GetEntity";
		      var url = "test?flog=1";
			  xhr.open("POST", url, true);
			  xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			  xhr.send("dcmpmethod="+dcmpmethod);
			  xhr.onreadystatechange = function() {		 
				if (xhr.readyState == 4 && xhr.status == 200) {    
					var result = xhr.responseText;					 
					document.getElementById("c_right").innerHTML=result;
				}
			}
		}
		
		function createXHR(){
	           var xhr;
	          if(window.XMLHttpRequest){
	             xhr = new XMLHttpRequest();   //ie7 火狐 
	          }else{
	             xhr  = new ActiveXObject("Microsoft.XMLHTTP"); //ie5,i6   
	          }
	          return xhr;
	      }
	      
	}

          function textEntity(){
              var right_text = document.getElementById("right_text").value;
              var form_btn_post = document.getElementById("form_btn_post");
               if(right_text.trim() == '' ){
                alert("请输入内容");
                return false;
                }
                else {
                form_btn_post.submit();
                return true;
                }
          }
          
           function inputEntity(){
             var right_text = document.getElementById("right_text").value;
             var form_btn_post = document.getElementById("form_btn_post");
               if(right_text.trim() == ''){
                alert("请输入内容");
                return false;
                }
                else {
                form_btn_post.submit();
                return true;
                } 
          }
	
   </script>
   </head>
   <body >
    <div class="username"><span style="color:red;">当前用户:${username}</span></div>
    <div class="content">
	    <div class="content_left">
		  <ul>
		     <li><span id="ReloadEntitybtn">ReloadEntity</span></li>
		     <li><span id="DeleteEntitybtn">DeleteEntity</span></li>
		     <li><span id="GetEntitybtn">GetEntity</span></li>
		  </ul>
	    </div>
		<div class="contetn_right" id="c_right"></div>
    </div>
	
	
   </body>
</html>
